function favorite(listingid) {
    url = "favorites.php";
    new Ajax.Request(url, {
        method : 'POST',
        parameters : {
            'listingid' : listingid
        },
        onSuccess : function (transport) {
            if (location.href.indexOf("favorites.php") > 0) {
                location.href = location.href;
            }
            else {
                // update the image if we can find it
                info = transport.responseText.split(":");
                if (info.length == 2) {
                    imgobj = $("favoriteimage_" + info[0]);
                    imgpath = info[1];

                    imgobj.setAttribute("src",imgpath);
                }
                else {
                    // some kind of error...
                }
            }
        }
    });
}
